package cn.javaxc.model.page;
import cn.javaxc.mvcwork.framework.beans.TFormBean;
import cn.javaxc.model.base.SQLMap;
import java.util.*;
import org.springframework.stereotype.Component;
import org.springframework.context.annotation.Scope;

/**
 * 框架调度Action使用的FormBean
 */
@Scope("prototype")
@Component("elementsmap")
public class VUEFormBean extends TFormBean
{
	private Map<Integer,SQLMap> elements=null;
	private Map<Integer,SQLMap> recordList=null;
	private Map record;
	private List<String> errList;
	public VUEFormBean(){
		elements=new LinkedHashMap();
		recordList=new LinkedHashMap();
		record=new HashMap();
		errList=new ArrayList<String>();
	}
	public SQLMap getElement(int ei){
		if (elements.get(ei)==null){
			elements.put(ei,new SQLMap());
		}
		return elements.get(ei);
	}
	public Map<Integer,SQLMap> getElements(){
		return elements;
	}
	public SQLMap getRecordElement(int ei){
		if (recordList.get(ei)==null){
			recordList.put(ei,new SQLMap());
		}
		return recordList.get(ei);
	}
	public Map<Integer,SQLMap> getRecordList(){
		return recordList;
	}
	public List<SQLMap> getTableElements(String table){
		if (table.isEmpty())return new ArrayList(getElements().values());
		List<SQLMap> list=new ArrayList();
		for (SQLMap emt:getElements().values() ){
			if (table.equalsIgnoreCase(emt.getTableName())){
				list.add(emt);
			}
		}
		return list;
	}
	public Map getRecord(){
		return this.record;
	}
	public void setRecord(Map record){
		this.record=record;
	}
	public List<String> getErrList() {
		return errList;
	}
	public String toString(){
		return "error:"+getErrList()+",data:"+elements.size()+",record"+record.size()+",record"+recordList.size();
	}


}
